#include <stdio.h>
#include <stdlib.h>
#define N 10

typedef struct ConnectVector
{
	int* tem;
}CV;

typedef struct Node
{
	int begin;
	int end;
	int size;
}Node;

void Init(CV* root ,Node* node)
{
	int* _tem = (int*)malloc(sizeof(int) * N);
	if (_tem == NULL)
	{
		perror("malloc fail");
		exit(1);
	}
	node->size = 0;
	root->tem = _tem;
	node->begin = 0;
	node->end = 0;
}


void push(CV* root, Node* node, int x)
{
	if (node->size < 9)
	{
		int count = (node->end + N) % N;
		*(root->tem + count) = x;
		node->end++;
		node->size++;
	}
}

void erase(CV* root, Node* node)
{
	if (node->begin != node->end)
	{
		int count = (node->begin + N) % N + 1;
		node->begin = count;
		node->size--;
	}
}

int main()
{
	CV tem;
	Node node;
	Init(&tem, &node);
	push(&tem, &node, 1);
	push(&tem, &node, 2);
	push(&tem, &node, 3);
	push(&tem, &node, 4);
	erase(&tem, &node);
	erase(&tem, &node);
	push(&tem, &node, 5);

	for (int i = 0; i < node.size;i++)
	{
		int count = (i + N + node.begin) % N;
		printf("%d ", *(tem.tem + count));
	}


	free(tem.tem);
	return 0;
}